/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.knowledge;


import org.apache.commons.lang3.StringUtils;

/**
 * 资产分类
 * @author zpy
 * @version 1.0.0
 */
public enum AssetClassification {
    /**物理环境**/
    PHY_ENV("ac1", "物理环境"),
    /**物理安防设施**/
    PHY_SECURITY("ac2", "物理安防设施"),
    /**密码产品**/
    PWD_PRODUCT("ac3", "密码产品"),
    /**服务器存储设备**/
    SERVER_STORAGE("ac4", "服务器/存储设备", "服务器存储设备"),
    /**网络及安全设备**/
    NETWORK_SECURITY("ac5", "网络及安全设备"),
    /**数据库管理系统**/
    DATABASE("ac6", "数据库管理系统"),
    /**关键业务应用**/
    KEY_BUSINESS("ac7", "关键业务应用"),
    /**子对象**/
    SUB_BUSINESS("ac7-1", "子对象"),
    /**重要数据**/
    KEY_DATA("ac8", "重要数据"),
    /**通信信道**/
    COMMUNICATION_CHANNEL("ac9", "通信信道"),
    /**管理类文档**/
    MANAGE_DOC("ac10", "管理类文档");

    private final String id;
    private final String name;
    private final String alias;

    AssetClassification(String id, String name) {
        this(id, name, name);
    }

    AssetClassification(String id, String name,String alias) {
        this.id = id;
        this.name = name;
        this.alias = alias;
    }

    public static AssetClassification fromId(String id){
        AssetClassification data = null;
        for(AssetClassification tt : AssetClassification.values()){
            if(StringUtils.equals(tt.id,id)){
                data = tt;
                break;
            }
        }
        return data;
    }

    public static AssetClassification fromName(String nameOrAlias){
        AssetClassification data = null;
        for(AssetClassification tt : AssetClassification.values()){
            if(StringUtils.equals(tt.name,nameOrAlias)
                    || StringUtils.equals(tt.alias,nameOrAlias)){
                data = tt;
                break;
            }
        }
        return data;
    }

    public String getId(){
        return this.id;
    }

    public String getName(){
        return this.name;
    }

    public String getAlias(){
        return this.alias;
    }
}